#include "AppDelegate.h"

#include <cocos2d.h>
#include <CCEGLView.h>
#include <CCLuaEngine.h>
#include <SimpleAudioEngine.h>

#include "MainMenuScene.h"

#include "InputManager.h"

using namespace CocosDenshion;
using namespace cocos2d;

AppDelegate::AppDelegate()
{

}

AppDelegate::~AppDelegate()
{
    SimpleAudioEngine::end();
}

bool AppDelegate::applicationDidFinishLaunching() 
{
	CCDirector *pDirector = CCDirector::sharedDirector();
	pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());

	pDirector->setDisplayStats(true);

	pDirector->setAnimationInterval(1.0 / 60);

	CCFileUtils::setResourcePath("..\\..\\Data\\");

	InputManager::getSingletonPtr()->initialise();
	
	CCScene *pScene = MainMenuScene::node();
	
	pDirector->runWithScene(pScene);

	return true;
}

void AppDelegate::applicationDidEnterBackground()
{
    CCDirector::sharedDirector()->pause();

    SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}

void AppDelegate::applicationWillEnterForeground()
{
    CCDirector::sharedDirector()->resume();

    SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
